<?php

include('php/generic_include.php');

session_start();
if (isset($_COOKIE['connected'])) setcookie('connected', clear($_COOKIE['connected']), time()+60*60*24*31);
if (isset($_SESSION['logged'])) setcookie('connected', clear($_SESSION['logged']), time() + 60 * 60 * 24 * 31);
if (clear($_GET['logout']) == 1) {
  setcookie('connected', '', time() - 20);
  session_destroy();
  header('Location: index.php');
}

mysql_connect('localhost', 'root', '');
mysql_select_db('root');


$page = 'txt/presentation.html';
if (isset($_GET['page'])) {
  $fichier = clear($_GET['page']);
  if (preg_match('#html$#', $fichier))
    $page = 'txt/' . $fichier;
  elseif (preg_match('#php$#', $fichier))
    $page = 'inc/' . $fichier;
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  <head>
    <meta http-equiv="Content-Type" content="text/html charset=utf8" />
    <meta name="author" content="stern_d, merbou_l, diallo_l" />
    <meta name="description" content="Rattrapage HTML, CSS, PHP" />
    <meta name="keywords" content="tp, rattrapage, html, webacademie, css, php, sql, piscine, openpiscine" />
    <link rel="stylesheet" href="./css/style.css" type="text/css" media="screen" />
    <title>After-Piscine</title>
  </head>
  <body>

    <?php include('inc/header.template'); ?>

    <!-- Début content -->
    <div class="content">
      <div class="wrapper">
	<div class="left main">

	  <?php
      if (file_exists($page))
	include($page);
      else
	include('txt/404.html');
	?>
	<br/>
	<br/>
	<br/>
	  <div class="ligne"></div><!--Laisse c est la ligne pr delimiter -->
	</div>
	<div class="clear"></div>
      </div>
    </div>
    <!--FIN CONTENT-->
    <?php include('inc/footer.template'); ?>
  </body>
</html>
